/*
 *  Copyright 2020-2021 Li Fei
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.pengshun.modules.api.coal.controller;

import com.fasterxml.jackson.annotation.JsonView;
import com.pengshun.modules.api.coal.para.CoalParam;
import com.pengshun.modules.api.coal.service.CoalService;
import com.pengshun.modules.api.coal.service.dto.CoalDto;
import com.pengshun.modules.api.coal.validator.First;
import com.pengshun.modules.api.coal.validator.Second;
import com.pengshun.modules.api.coal.validator.Third;
import com.pengshun.modules.common.BaseResult;
import com.pengshun.modules.common.ReslutView;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import springfox.documentation.annotations.ApiIgnore;


/**
 * @author lifei
 * @date 2020-11-06
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "矿口煤炭管理")
@RequestMapping("/api/coal")
public class CoalController {

    private final CoalService coalService;


    @ApiOperation(value = "查询矿口煤炭价格趋势")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型 ", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "coalId", value = "煤炭id ", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "date", value = "日期", dataType = "date", paramType = "query"),
    })
    @GetMapping(value = "/price")
    public BaseResult selectCoalPriceByMineMouthId(@ApiIgnore @Validated(value = {First.class}) CoalParam form) throws Exception {
        BaseResult res = coalService.selectCoalPriceByMineMouthId(form);
        return res;
    }

    @ApiOperation(value = "查询煤炭柱状图")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "年传1 月传2 ", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始年份 ", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束年份 ", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "coalId", value = "煤炭id ", dataType = "int", required = true, paramType = "query"),
    })
    @GetMapping(value = "/price/year")
    public BaseResult selectCoalPriceByCoalId(@ApiIgnore @Validated(value = {First.class}) CoalParam form) throws Exception {
        BaseResult res = coalService.selectCoalPriceByCoalId(form);
        return res;

    }

    @ApiOperation(value = "查询煤炭折线图")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sDate", value = "开始年份 ", dataType = "string", required = true, paramType = "query"),
            @ApiImplicitParam(name = "eDate", value = "结束年份 ", dataType = "string", required = true, paramType = "query"),
            @ApiImplicitParam(name = "coalId", value = "煤炭id ", dataType = "int", required = true, paramType = "query"),
    })
    @GetMapping(value = "/coal-broken-line")
    public BaseResult selectCoalBrokenLine(@ApiIgnore @Validated(value = {First.class}) CoalParam form) throws Exception {
        BaseResult res = coalService.selectCoalBrokenLine(form);
        return res;

    }

    @ApiOperation(value = "查询煤炭K线图")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "day", value = "1年传12 2年传24 类推 ", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "coalId", value = "煤炭id ", dataType = "int", required = true, paramType = "query"),
    })
    @JsonView(ReslutView.aView.class)
    @GetMapping(value = "/price/kline")
    public BaseResult selectCoalKline(@ApiIgnore @Validated(value = {First.class}) CoalParam form) throws Exception {
        BaseResult res = coalService.selectCoalKline(form);
        return res;

    }


    @ApiOperation("查询煤炭详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "coalId", value = "煤炭id ", dataType = "int", required = true, paramType = "query"),
    })
    @GetMapping(value = "/detil")
    public BaseResult selectCoalDetil(@ApiIgnore @Validated(value = {Third.class}) CoalDto para) throws Exception {
        BaseResult res = coalService.selectCoalDetil(para.getCoalId());
        return res;
    }


    @ApiOperation("查询矿口煤炭种类")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mineMouthId", value = "矿口id", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "categoryCode", value = "煤矿类型编码", dataType = "string", paramType = "query")
    })
    @GetMapping(value = "/code")
    public BaseResult selectCoalCode(@ApiIgnore @Validated(value = {Second.class}) CoalParam para) throws Exception {
        BaseResult res = coalService.selectCoalCode(para);
        return res;
    }

    @ApiOperation("查询煤炭种类")
    @GetMapping(value = "/category")
    public BaseResult selectCoalCode() {
        BaseResult res = coalService.selectCoalCategory( );
        return res;
    }



//    @Log("煤炭发布")
//    @ApiOperation(value = "煤炭发布")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "mineMouthId", value = "矿口id", dataType = "int", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "煤炭名称 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "coalPrice", value = "煤矿价格", dataType = "double", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "priceUnit", value = "煤炭单位 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "calorificValue", value = "发热量 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "coalTechnologyName", value = "煤炭工艺 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "coalTechnologyCode", value = "煤炭工艺编码 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "categoryName", value = "煤炭类型 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "categoryCode", value = "煤炭类型编码 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "laboratoryTime", value = "煤炭类型编码 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "categoryCode", value = "化验时间 ", dataType = "date", paramType = "query"),
//            @ApiImplicitParam(name = "laboratoryBillPic", value = "化验单图片 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "laboratoryCompany", value = "化验单单位 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "coalPic", value = "煤炭图片 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "coalInfos[0].categoryKey", value = "key唯一编码 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "coalInfos[0].value", value = "值", dataType = "string", paramType = "query"),
//    })
//    @GetMapping(value = "/save")
//    public BaseResult save(@ApiIgnore @Validated(value = {First.class}) CoalDto form) throws Exception {
//        BaseResult res = coalService.save(form);
//        return res;
//    }
//
//    @Log("煤炭更新")
//    @ApiOperation(value = "煤炭更新")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "mineMouthId", value = "矿口id", dataType = "int", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "coalId", value = "煤炭id", dataType = "int", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "煤炭名称 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "coalPrice", value = "煤矿价格", dataType = "double", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "priceUnit", value = "煤炭单位 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "calorificValue", value = "发热量 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "coalTechnologyName", value = "煤炭工艺 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "coalTechnologyCode", value = "煤炭工艺编码 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "categoryName", value = "煤炭类型 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "categoryCode", value = "煤炭类型编码 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "laboratoryTime", value = "煤炭类型编码 ", dataType = "string", required = true, paramType = "query"),
//            @ApiImplicitParam(name = "categoryCode", value = "化验时间 ", dataType = "date", paramType = "query"),
//            @ApiImplicitParam(name = "laboratoryBillPic", value = "化验单图片 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "laboratoryCompany", value = "化验单单位 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "status", value = "状态(状态0:删除 1:发布 3:关闭) ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "coalPic", value = "煤炭图片 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "coalInfos[0].categoryKey", value = "key唯一编码 ", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "coalInfos[0].value", value = "值", dataType = "string", paramType = "query"),
//    })
//    @GetMapping(value = "/update")
//    public BaseResult update(@ApiIgnore @Validated(value = {First.class}) CoalDto form) throws Exception {
//        BaseResult res = coalService.update(form);
//        return res;
//    }

}